package com.sh.data.engine.domain.integration.datasource.model.domain;

import com.sh.data.engine.common.enumDefinition.DSType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/13 10:18
 */
@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
@NoArgsConstructor
public class DataSourceDetailDomain extends DataSourceDomain {

    private String connectionProperty;

    private String username;

    private String password;

//    private String dbName;

    private HiveConfig hiveConfig;

    private MongoConfig mongoConfig;

    private HDFSConfig hdfsConfig;

    private MaxComputeConfig maxComputeConfig;

    private RdbmsConfig rdbmsConfig;

    @Data
    public static class RdbmsConfig {

        private String dbName;

        private Integer port;

        private String server;

        private String version;

        private Integer oracleConnectionType;

        private String schema;
    }

    @Data
    public static class HiveConfig {

        private String dbName;

        private Integer port;

        private String server;

        private String version;

        private String hiveSiteAddress;

        private String originalFilename;
    }

    @Data
    public static class MongoConfig {

        private String authDbName;

        private String port;

        private String server;
    }

    @Data
    public static class HDFSConfig {

        /**
         * hdfs的用户
         */
        private String server;

        private Integer port;
    }

    @Data
    public static class MaxComputeConfig {
        private String accessId;

        /**
         * accessKey
         */
        private String accessKey;

        /**
         * 项目
         */
        private String project;

        /**
         * endPoint
         */
        private String endPoint;

        /**
         * endPoint
         */
        private String tunnelEndPoint;
    }

    public Boolean isHive() {
        return this.getDsType().equalsIgnoreCase(DSType.Hive.name());
    }

    public Boolean isMongoHbase() {
        return this.getDsType().equalsIgnoreCase(DSType.Mongodb.name())
            || this.getDsType().equalsIgnoreCase(DSType.HBase.name());
    }

    public Boolean isRelatedDs() {
        return !this.getDsType().equalsIgnoreCase(DSType.Hive.name())
            && !this.getDsType().equalsIgnoreCase(DSType.Mongodb.name())
            && !this.getDsType().equalsIgnoreCase(DSType.HBase.name());
    }
}
